<template>
  <swiper>
    <swiper-item v-for="item in banners">
      <a :href="item.link">
        <img :src="item.image" alt="" @load="imgload">
      </a>
    </swiper-item>
  </swiper>
</template>

<script>
  import {Swiper, SwiperItem} from '@/components/common/swiper'

  export default {
    name: "HomeSwiper",
    //还要把数据给弄过来
    props: {
      banners: {
        type: Array,
        default() {
          return []
        }
      }
    },
    data(){
      return{
        //图片是否有一次加载
        isLoad:false,
      }
    },
    components: {
      Swiper,
      SwiperItem
    },
    methods:{
      imgload(){
        //第一次进来为true 之后就进不来了★★★ 仅发送一次emit
        if(!this.isLoad){
          this.$emit('swiperImgLoad');
          this.isLoad = true
        }
      }
    }
  }
</script>

<style scoped>

</style>
